

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>mindspore.nn.Conv3dTranspose &mdash; MindSpore master documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="mindspore.nn.Jvp" href="mindspore.nn.Jvp.html" />
    <link rel="prev" title="mindspore.nn.Conv3d" href="mindspore.nn.Conv3d.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> MindSpore
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">MindSpore Python API</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../mindspore.html">mindspore</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.common.initializer.html">mindspore.common.initializer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.communication.html">mindspore.communication</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.compression.html">mindspore.compression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.context.html">mindspore.context</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.html">mindspore.dataset</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.audio.html">mindspore.dataset.audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.config.html">mindspore.dataset.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.text.html">mindspore.dataset.text</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.transforms.html">mindspore.dataset.transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.vision.html">mindspore.dataset.vision</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.mindrecord.html">mindspore.mindrecord</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../mindspore.nn.html">mindspore.nn</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id1">基本构成单元</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id2">容器</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../mindspore.nn.html#id3">卷积层</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Conv1d.html">mindspore.nn.Conv1d</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Conv1dTranspose.html">mindspore.nn.Conv1dTranspose</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Conv2d.html">mindspore.nn.Conv2d</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Conv2dTranspose.html">mindspore.nn.Conv2dTranspose</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.Conv3d.html">mindspore.nn.Conv3d</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">mindspore.nn.Conv3dTranspose</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id4">梯度</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id5">循环层</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id6">稀疏层</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id7">非线性激活函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id8">工具</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id9">图像</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id10">归一化层</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id11">池化层</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id12">量化</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id13">损失函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id14">优化器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#wrapper">Wrapper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id15">数学运算</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id16">评估指标</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.html#id17">动态学习率</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.probability.html">mindspore.nn.probability</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.transformer.html">mindspore.nn.transformer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.numpy.html">mindspore.numpy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.ops.html">mindspore.ops</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.html">mindspore.parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.nn.html">mindspore.parallel.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.profiler.html">mindspore.profiler</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.scipy.html">mindspore.scipy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.train.html">mindspore.train</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.boost.html">mindspore.boost</a></li>
</ul>
<p class="caption"><span class="caption-text">MindSpore C++ API</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://www.mindspore.cn/lite/api/zh-CN/master/api_cpp/mindspore.html">MindSpore Lite↗</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">MindSpore</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../mindspore.nn.html">mindspore.nn</a> &raquo;</li>
        
      <li>mindspore.nn.Conv3dTranspose</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/api_python/nn/mindspore.nn.Conv3dTranspose.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="mindspore-nn-conv3dtranspose">
<h1>mindspore.nn.Conv3dTranspose<a class="headerlink" href="#mindspore-nn-conv3dtranspose" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="mindspore.nn.Conv3dTranspose">
<em class="property">class </em><code class="sig-prename descclassname">mindspore.nn.</code><code class="sig-name descname">Conv3dTranspose</code><span class="sig-paren">(</span><em class="sig-param">in_channels</em>, <em class="sig-param">out_channels</em>, <em class="sig-param">kernel_size</em>, <em class="sig-param">stride=1</em>, <em class="sig-param">pad_mode='same'</em>, <em class="sig-param">padding=0</em>, <em class="sig-param">dilation=1</em>, <em class="sig-param">group=1</em>, <em class="sig-param">output_padding=0</em>, <em class="sig-param">has_bias=False</em>, <em class="sig-param">weight_init='normal'</em>, <em class="sig-param">bias_init='zeros'</em>, <em class="sig-param">data_format='NCDHW'</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.nn.Conv3dTranspose" title="Permalink to this definition">¶</a></dt>
<dd><p>三维转置卷积层。</p>
<p>计算三维转置卷积，可以视为Conv3d对输入求梯度，也称为反卷积（实际不是真正的反卷积）。</p>
<p>输入的shape通常为 <span class="math notranslate nohighlight">\((N, C_{in}, D_{in}, H_{in}, W_{in})\)</span> ，其中 <span class="math notranslate nohighlight">\(N\)</span> 为batch size， <span class="math notranslate nohighlight">\(C\)</span> 是空间维度。<span class="math notranslate nohighlight">\(D_{in}, H_{in}, W_{in}\)</span> 分别为特征层的深度、高度和宽度。
当Conv3d和ConvTranspose3d使用相同的参数初始化时，且 <cite>pad_mode</cite> 设置为”pad”，它们会在输入的深度、高度和宽度方向上填充 <span class="math notranslate nohighlight">\(dilation * (kernel\_size - 1) - padding\)</span> 个零，这种情况下它们的输入和输出shape是互逆的。
然而，当 <cite>stride</cite> 大于1时，Conv3d会将多个输入的shape映射到同一个输出shape。反卷积网络可以参考 <a class="reference external" href="https://www.matthewzeiler.com/mattzeiler/deconvolutionalnetworks.pdf">Deconvolutional Networks</a> 。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>in_channels</strong> (int) - Conv3dTranspose层输入Tensor的空间维度。</p></li>
<li><p><strong>out_channels</strong> (int) - Conv3dTranspose层输出Tensor的空间维度。</p></li>
<li><p><strong>kernel_size</strong> (Union[int, tuple[int]]) - 指定三维卷积核的深度、高度和宽度。数据类型为int或包含三个整数的tuple。一个整数表示卷积核的深度、高度和宽度均为该值该值。包含三个整数的tuple分别表示卷积核的深度、高度和宽度。</p></li>
<li><p><strong>stride</strong> (Union[int, tuple[int]]) - 三维卷积核的移动步长。数据类型为整型或三个整型的tuple。一个整数表示在深度、高度和宽度方向的移动步长均为该值。三个整数的tuple分别表示在深度、高度和宽度方向的移动步长。默认值：1。</p></li>
<li><p><strong>pad_mode</strong> (str) - 指定填充模式。可选值为”same”、”valid”、”pad”。默认值：”same”。</p>
<ul>
<li><p>same：输出的深度、高度和宽度分别与输入整除 <cite>stride</cite> 后的值相同。若设置该模式，<cite>padding</cite> 的值必须为0。</p></li>
<li><p>valid：在不填充的前提下返回有效计算所得的输出。不满足计算的多余像素会被丢弃。如果设置此模式，则 <cite>padding</cite> 的值必须为0。</p></li>
<li><p>pad：对输入进行填充。 在输入的深度、高度和宽度方向上填充 <cite>padding</cite> 大小的0。如果设置此模式， <cite>padding</cite> 必须大于或等于0。</p></li>
</ul>
</li>
<li><p><strong>padding</strong> (Union(int, tuple[int])) - 输入的深度、高度和宽度方向上填充的数量。数据类型为int或包含6个整数的tuple。如果 <cite>padding</cite> 是一个整数，则前部、后部、顶部，底部，左边和右边的填充都等于 <cite>padding</cite> 。如果 <cite>padding</cite> 是6个整数的tuple，则前部、尾部、顶部、底部、左边和右边的填充分别等于填充padding[0]、padding[1]、padding[2]、padding[3]、padding[4]和padding[5]。值应该要大于等于0，默认值：0。</p></li>
<li><p><strong>dilation</strong> (Union[int, tuple[int]]) - 三维卷积核膨胀尺寸。数据类型为int或三个整数的tuple。若 <span class="math notranslate nohighlight">\(k &gt; 1\)</span> ，则kernel间隔 <cite>k</cite> 个元素进行采样。深度、高度和宽度方向上的 ｀k｀ ，其取值范围分别为[1, D]、[1, H]和[1, W]。默认值：1。</p></li>
<li><p><strong>group</strong> (int) - 将过滤器拆分为组， <cite>in_channels</cite> 和 <cite>out_channels</cite> 必须可被 <cite>group</cite> 整除。当 <cite>group</cite> 大于1时，暂不支持Ascend平台。默认值：1。当前仅支持1。</p></li>
<li><p><strong>output_padding</strong> (Union(int, tuple[int])) - 输出的深度、高度和宽度方向上填充的数量。数据类型为int或包含6个整数的tuple。如果 <cite>output_padding</cite> 是一个整数，则前部、后部、顶部，底部，左边和右边的填充都等于 <cite>output_padding</cite> 。如果 <cite>output_padding</cite> 是6个整数的tuple，则前部、尾部、顶部、底部、左边和右边的填充分别等于填充output_padding[0]、output_padding[1]、output_padding[2]、output_padding[3]、output_padding[4]output_padding[5]。值应该要大于等于0，默认值：0。</p></li>
<li><p><strong>has_bias</strong> (bool) - Conv3dTranspose层是否添加偏置参数。默认值：False。</p></li>
<li><p><strong>weight_init</strong> (Union[Tensor, str, Initializer, numbers.Number]) - 权重参数的初始化方法。它可以是Tensor，str，Initializer或numbers.Number。当使用str时，可选”TruncatedNormal”，”Normal”，”Uniform”，”HeUniform”和”XavierUniform”分布以及常量”One”和”Zero”分布的值，可接受别名”xavier_uniform”，”he_uniform”，”ones”和”zeros”。上述字符串大小写均可。更多细节请参考Initializer的值。默认值：”normal”。</p></li>
<li><p><strong>bias_init</strong> (Union[Tensor, str, Initializer, numbers.Number]) - 偏置参数的初始化方法。可以使用的初始化方法与”weight_init”相同。更多细节请参考Initializer的值。默认值：”zeros”。</p></li>
<li><p><strong>data_format</strong> (str) - 数据格式的可选值。目前仅支持”NCDHW”。</p></li>
</ul>
<p><strong>输入：</strong></p>
<ul class="simple">
<li><p><strong>x</strong> (Tensor) - shape为 <span class="math notranslate nohighlight">\((N, C_{in}, D_{in}, H_{in}, W_{in})\)</span> 的Tensor。目前输入数据类型只支持float16和float32。</p></li>
</ul>
<p><strong>输出：</strong></p>
<p>Tensor，shape为 <span class="math notranslate nohighlight">\((N, C_{out}, D_{out}, H_{out}, W_{out})\)</span> 。</p>
<p>pad_mode为”same”时：</p>
<div class="math notranslate nohighlight">
\[\begin{split}\begin{array}{ll} \\
    D_{out} ＝ \left \lfloor{\frac{D_{in}}{\text{stride[0]}} + 1} \right \rfloor \\
    H_{out} ＝ \left \lfloor{\frac{H_{in}}{\text{stride[1]}} + 1} \right \rfloor \\
    W_{out} ＝ \left \lfloor{\frac{W_{in}}{\text{stride[2]}} + 1} \right \rfloor \\
\end{array}\end{split}\]</div>
<p>pad_mode为”valid”时：</p>
<div class="math notranslate nohighlight">
\[\begin{split}\begin{array}{ll} \\
    D_{out} ＝ \left \lfloor{\frac{D_{in} - \text{dilation[0]} \times (\text{kernel_size[0]} - 1) }
    {\text{stride[0]}} + 1} \right \rfloor \\
    H_{out} ＝ \left \lfloor{\frac{H_{in} - \text{dilation[1]} \times (\text{kernel_size[1]} - 1) }
    {\text{stride[1]}} + 1} \right \rfloor \\
    W_{out} ＝ \left \lfloor{\frac{W_{in} - \text{dilation[2]} \times (\text{kernel_size[2]} - 1) }
    {\text{stride[2]}} + 1} \right \rfloor \\
\end{array}\end{split}\]</div>
<p>pad_mode为”pad”时：</p>
<div class="math notranslate nohighlight">
\[\begin{split}\begin{array}{ll} \\
    D_{out} ＝ \left \lfloor{\frac{D_{in} + padding[0] + padding[1] - (\text{dilation[0]} - 1) \times
    \text{kernel_size[0]} - 1 }{\text{stride[0]}} + 1} \right \rfloor \\
    H_{out} ＝ \left \lfloor{\frac{H_{in} + padding[2] + padding[3] - (\text{dilation[1]} - 1) \times
    \text{kernel_size[1]} - 1 }{\text{stride[1]}} + 1} \right \rfloor \\
    W_{out} ＝ \left \lfloor{\frac{W_{in} + padding[4] + padding[5] - (\text{dilation[2]} - 1) \times
    \text{kernel_size[2]} - 1 }{\text{stride[2]}} + 1} \right \rfloor \\
\end{array}\end{split}\]</div>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>TypeError</strong> - <cite>in_channels</cite> 、 <cite>out_channels</cite> 或 <cite>group</cite> 不是int。</p></li>
<li><p><strong>TypeError</strong> - <cite>kernel_size</cite> 、 <cite>stride</cite> 、 <cite>padding</cite> 、 <cite>dilation</cite> 或 <cite>output_padding</cite> 既不是int也不是tuple。</p></li>
<li><p><strong>TypeError</strong> - 输入数据类型不是float16或float32。</p></li>
<li><p><strong>ValueError</strong> - <cite>in_channels</cite> 、 <cite>out_channels</cite> 、 <cite>kernel_size</cite> 、 <cite>stride</cite> 或 <cite>dilation</cite> 小于1。</p></li>
<li><p><strong>ValueError</strong> - <cite>padding</cite> 小于0。</p></li>
<li><p><strong>ValueError</strong> - <cite>pad_mode</cite> 不是”same”，”valid”或”pad”。</p></li>
<li><p><strong>ValueError</strong> - <cite>padding</cite> 是长度不等于6的tuple。</p></li>
<li><p><strong>ValueError</strong> - <cite>pad_mode</cite> 不等于”pad”且 <cite>padding</cite> 不等于(0, 0, 0, 0, 0, 0)。</p></li>
<li><p><strong>ValueError</strong> - <cite>data_format</cite> 不是”NCDHW”。</p></li>
</ul>
<p><strong>支持平台：</strong></p>
<p><code class="docutils literal notranslate"><span class="pre">Ascend</span></code> <code class="docutils literal notranslate"><span class="pre">GPU</span></code></p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Tensor</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">([</span><span class="mi">32</span><span class="p">,</span> <span class="mi">16</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">32</span><span class="p">,</span> <span class="mi">32</span><span class="p">]),</span> <span class="n">mindspore</span><span class="o">.</span><span class="n">float32</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">conv3d_transpose</span> <span class="o">=</span> <span class="n">nn</span><span class="o">.</span><span class="n">Conv3dTranspose</span><span class="p">(</span><span class="n">in_channels</span><span class="o">=</span><span class="mi">16</span><span class="p">,</span> <span class="n">out_channels</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">kernel_size</span><span class="o">=</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span>
<span class="gp">... </span>                                      <span class="n">pad_mode</span><span class="o">=</span><span class="s1">&#39;pad&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">output</span> <span class="o">=</span> <span class="n">conv3d_transpose</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">output</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
<span class="go">(32, 3, 13, 37, 33)</span>
</pre></div>
</div>
</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="mindspore.nn.Jvp.html" class="btn btn-neutral float-right" title="mindspore.nn.Jvp" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="mindspore.nn.Conv3d.html" class="btn btn-neutral float-left" title="mindspore.nn.Conv3d" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2021, MindSpore.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>